<?php 
	class DBConn
	{
		private $connectString=NULL;
		private $host="localhost";
		private $username="root";
		private $password="root";
		private $database="lib";
		private $result=NULL;
		private $link=NULL;
		
		
		public function DBConn()
		{
/*			$this->connectString=mysqli_connect($this->host,$this->username,$this->password);
			mysql_select_db($this->connectString,$this->database);
			mysql_query("set names 'utf-8'");*/
			$this->link = mysqli_connect($this->host,$this->username,$this->password,$this->database);
			if(mysqli_connect_errno())
			{
				printf("Connect fail: %s\n",mysqli_connect_error());
				exit();	
			}

		}
		
		public function GetDataByQuery($query)
		{
			$this->result=mysqli_query($this->link,$query);
		}
		
		public function FetchRow()
		{
			if(!is_resource($this->result)) 
				return false;
			return mysqli_fetch_assoc($this->result);
		}
		
		public function LoadMenuParent()
		{
			$sqlQuery="SELECT idMenu,nameMenu,linkMenu,titleMenu,newPageMenu 
                     FROM menu WHERE isPublished = '1' and isParent = '1'  order by 'order' ASC";
			return mysqli_query($this->link,$sqlQuery) or die (mysqli_error());
		}
		
		public function LoadMenuChild($row)
		{
			$sqlQuery="SELECT idMenu,nameMenu,linkMenu,titleMenu,newPageMenu FROM menu 
                        WHERE isPublished = '1' and isParent = '0' and parentId = '".$row['idMenu']."' order by 'order' ASC";
			return mysqli_query($this->link,$sqlQuery) or die (mysqli_error());
		}
	}
	
?>